<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>购物返现设置</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  {include file="public/css"/}
</head>
<body>
  <div class="layui-fluid">
    <div class="layui-row layui-col-space15">
      <div class="layui-card layui-col-md12">
                <div class="layui-card-header">
                    {if !$info['id']}<i class="fa fa-plus"></i> 添加购物返现{else}<i class="fa fa-pencil"></i> 编辑购物返现{/if}
                    <i class="layui-icon layui-icon-close" style="font-size:18px;font-weight:bold;cursor:pointer" onclick="closeself()"></i>
                </div>
                <div class="layui-card-body" pad15>
                    <div class="layui-form form-label-w8" lay-filter="">
                        <input type="hidden" name="info[id]" value="{$info['id']}">

                        <div class="layui-form-item">
                            <label class="layui-form-label">活动名称：</label>
                            <div class="layui-input-inline" style="width:300px">
                                <input type="text" name="info[name]" value="{$info.name}" lay-verify="required" lay-verType="tips" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">返现比例：</label>
                            <div class="layui-input-inline" >
                                <input type="text" name="info[back_ratio]" value="{$info.back_ratio}"  class="layui-input">
                            </div>
                            <div class="layui-form-mid">%</div>
                        </div>
                        {if getcustom('cashback_receiver')}
                        <div class="layui-form-item" >
                            <label class="layui-form-label">受益人：</label>
                            <div class="layui-input-inline" style="width:250px">
                                <input type="radio" name="info[receiver_type]" value="1" {if !$info['id'] || $info['receiver_type']==1}checked{/if} title="自己" />
                                <input type="radio" name="info[receiver_type]" value="2" {if $info['receiver_type']==2}checked{/if} title="参与活动的人" />
                            </div>
                            <div class="layui-form-mid layui-word-aux"> 注：仅限单个指定商品 参与活动人平均分配，通过限额控制最大分配</div>
                        </div>
                        {/if}
                        {if getcustom('yx_cashback_pid')}
                        <div class="layui-form-item" >
                            <label class="layui-form-label">返现人：</label>
                            <div class="layui-input-inline" style="width:250px">
                                <input type="radio" name="info[cashback_pid]" value="0" {if !$info['id'] || $info['cashback_pid']==0}checked{/if} title="自己" />
                                <input type="radio" name="info[cashback_pid]" value="1" {if $info['cashback_pid']==1}checked{/if} title="直推" />
                            </div>
                            <div class="layui-form-mid layui-word-aux"> 选择直推，购物返现金额优先发放直推上级，没有上级的不发放</div>
                        </div>
                        {/if}
                        {if getcustom('cashback_max')}
                        <div class="layui-form-item" >
                            <label class="layui-form-label">返现额度倍数：</label>
                            <div class="layui-input-inline" style="width:250px">
                                <input type="number" name="info[goods_multiple_max]" value="{$info.goods_multiple_max}"
                                       min="0"
                                       class="layui-input">
                            </div>
                            <div class="layui-form-mid layui-word-aux"> 注：每人最高返现额度，仅限单个指定商品，商品售价的N倍（满额停止返现）0或空 不限制</div>
                        </div>
                        {/if}

                        {if getcustom('yx_cashback_sendtype')}
                        <div class="layui-form-item" >
                            <label class="layui-form-label">发放类型：</label>
                            <div class="layui-input-inline" style="width:250px">
                                <input type="radio" name="info[sendtype]" value="1" {if $info['sendtype']==1}checked{/if} title="付款后" />
                                <input type="radio" name="info[sendtype]" value="2" {if !$info['id'] || $info['sendtype']==2}checked{/if} title="确认收货后" />
                            </div>
                            <div class="layui-form-mid layui-word-aux">
                                选择付款后，则仅订单支付完将走此购物返现的流程，确认收货时不再走此购物返现的流程；选择确认收货后，则仅订单确认收货完将走此购物返现的流程
                            </div>
                        </div>
                        {/if}

                        <div class="layui-form-item" >
                            <label class="layui-form-label">返现类型：</label>
                            <div class="layui-input-inline" style="width:250px">
                                <input type="radio" name="info[back_type]" value="1" {if !$info['id'] || $info['back_type']==1}checked{/if} title="余额" />
                                <input type="radio" name="info[back_type]" value="2" {if $info['back_type']==2}checked{/if} title="佣金" />
                                <input type="radio" name="info[back_type]" value="3" {if $info['back_type']==3}checked{/if} title="积分" />
                            </div>
                            <div class="layui-form-mid layui-word-aux"> 注：{if getcustom('yx_cashback_sendtype')}付款/{/if}确认收货后返还到用户的余额/佣金/积分账户</div>
                        </div>

                        {if $return_type}
                            <div class="layui-form-item" style="margin-bottom: 5px">
                                <label class="layui-form-label">返现时间：</label>
                                <div class="layui-input-inline" style="width:660px">
                                    <input type="radio" name="info[return_type]" value="0" {if $info['return_type']==0}checked{/if} title="立即返还" lay-filter="return_type"/>
                                    {if getcustom('yx_cashback_time')}
                                    <input type="radio" name="info[return_type]" value="1" {if $info['return_type']==1}checked{/if} title="自定义" lay-filter="return_type"/>
                                    {/if}
                                    {if getcustom('yx_cashback_stage')}
                                    <input type="radio" name="info[return_type]" value="2" {if $info['return_type']==2}checked{/if} title="阶梯返还" lay-filter="return_type"/>
                                    {/if}
                                    {if getcustom('yx_cashback_multiply')}
                                    <input type="radio" name="info[return_type]" value="3" {if $info['return_type']==3}checked{/if} title="倍增" lay-filter="return_type"/>
                                    {/if}
                                    {if getcustom('yx_cashback_addup_return') &&  ($auth_data =='all' || in_array('CashbackAddup',$auth_data))}
                                    <input type="radio" name="info[return_type]" value="4" {if $info['return_type']==4}checked{/if} title="叠加递减" lay-filter="return_type"/>
                                    {/if}
                                </div>
                            </div>
                            {if getcustom('yx_cashback_time')}
                                <div class="return_type1" style="display:{if $info['return_type']!=1}none{/if}">
                                    <div class="layui-form-item">
                                        <label class="layui-form-label"></label>
                                        {if getcustom('yx_cashback_time_delaysend')}
                                        <span style="display:{if $info['return_type']!=1}none{/if};margin-right: 20px;" id="delaysend_day">确认收货后第<input type="text"  name="info[delaysend_day]"  value="{$info.delaysend_day}" class="layui-input" style="display: inline-block;width: 100px;" > 天开始返现 </span>
                                        {/if}
                                        <span style="display:{if $info['return_type']!=1}none{/if};" id="return_day"><input type="text"  name="info[return_day]"  value="{$info.return_day}" class="layui-input" style="display: inline-block;width: 100px;" > 天返还完</span>
                                        {if getcustom('yx_cashback_jiange_day')}
                                        <span style="display:{if $info['return_type']!=1}none{/if};" id="jiange_day">，返现间隔天数 <input type="text" name="info[jiange_day]"  value="{$info.jiange_day}" class="layui-input" style="display: inline-block;width: 100px;" > 天</span>
                                        {/if}
                                        
                                    </div>
                                </div>
                            {/if}
                            {if getcustom('yx_cashback_stage')}
                                <div class="return_type2" style="display:{if $info['return_type']!=2}none{/if}">
                                    <div id="stageset_div">
                                        {php} $stagedata = json_decode($info['stagedata'],true);{/php}
                                        {if $stagedata}
                                        {foreach $stagedata as $k=>$stage}
                                        <div class="layui-form-item">
                                            <label class="layui-form-label"></label>
                                            <div class="layui-form-mid">第</div>
                                            <div class="layui-input-inline" style="width:70px"><input type="text" name="stageday[]" value="{$stage.stageday}" class="layui-input"></div>
                                            <div class="layui-form-mid">天 ~ 第</div>
                                            <div class="layui-input-inline" style="width:70px"><input type="text" name="stageday2[]" value="{$stage.stageday2}" class="layui-input"></div>
                                            <div class="layui-form-mid">天，每天返回</div>
                                            <div class="layui-input-inline" style="width:70px"><input type="text" name="stageratio[]" value="{$stage.stageratio}" class="layui-input"></div>
                                            <div class="layui-form-mid">%</div>
                                            {if $k==0}
                                            <button type="button" class="layui-btn layui-btn-primary" onclick="adddatastage()">新增</button>
                                            {else}
                                            <button type="button" class="layui-btn layui-btn-primary" onclick="deldatastage(this)">删除</button>
                                            {/if}
                                        </div>
                                        {/foreach}
                                        {else}
                                        <div class="layui-form-item">
                                            <label class="layui-form-label"></label>
                                            <div class="layui-form-mid">第</div>
                                            <div class="layui-input-inline" style="width:70px"><input type="text" name="stageday[]" value="" class="layui-input"></div>
                                            <div class="layui-form-mid">天 ~ 第</div>
                                            <div class="layui-input-inline" style="width:70px"><input type="text" name="stageday2[]" value="" class="layui-input"></div>
                                            <div class="layui-form-mid">天，每天返回</div>
                                            <div class="layui-input-inline" style="width:70px"><input type="text" name="stageratio[]" value="" class="layui-input"></div>
                                            <div class="layui-form-mid">%</div>
                                            <button type="button" class="layui-btn layui-btn-primary" onclick="adddatastage()">新增</button>
                                        </div>
                                        {/if}
                                    </div>
                                    <script>
                                    function adddatastage(){
                                        var html = '';
                                        html+='<div class="layui-form-item">';
                                        html+=' <label class="layui-form-label"></label>';
                                        html+=' <div class="layui-form-mid">第</div>';
                                        html+=' <div class="layui-input-inline" style="width:70px"><input type="text" name="stageday[]" value="" class="layui-input"></div>';
                                        html+=' <div class="layui-form-mid">天 ~ 第</div>';
                                        html+=' <div class="layui-input-inline" style="width:70px"><input type="text" name="stageday2[]" value="" class="layui-input"></div>';
                                        html+=' <div class="layui-form-mid">天，每天返回</div>';
                                        html+=' <div class="layui-input-inline" style="width:70px"><input type="text" name="stageratio[]" value="" class="layui-input"></div>';
                                        html+=' <div class="layui-form-mid">%</div>';
                                        html+=' <button type="button" class="layui-btn layui-btn-primary" onclick="deldatastage(this)">删除</button>';
                                        html+='</div>';
                                        $('#stageset_div').append(html);
                                    }
                                    function deldatastage(obj){
                                        $(obj).parent().remove();
                                    }
                                    </script>
                                </div>
                            {/if}
                        {if getcustom('yx_cashback_multiply')}
                        <div class="return_type3" style="display:{if $info['return_type']!=3}none{/if}">
                            <div class="layui-form-item">
                                <label class="layui-form-label"></label>
                                <span style="margin-right: 20px;" >首期返现<input type="text"  name="info[first_circle]"  value="{$info.first_circle}" class="layui-input" style="display: inline-block;width: 100px;" >% </span>
                                <span>每期业绩增长达到上一期的<input type="text"  name="info[circle_add]"  value="{$info.circle_add}" class="layui-input" style="display: inline-block;width: 100px;" > %返现</span>
                                <span>,总期数 <input type="text" name="info[circle_max]"  value="{$info.circle_max}" class="layui-input" style="display: inline-block;width: 100px;" > 期</span>
                            </div>
                            {if getcustom('active_coin') && getcustom('yx_cashback_multiply_yejitype')}
                            <div class="layui-form-item" >
                                <label class="layui-form-label" style="width: 150px">倍增业绩对象：</label>
                                <div class="layui-form-mid layui-word-aux">系统设置-分销分红-倍增购物返现 处设置</div>
                            </div>
                            {/if}
                            <div class="layui-form-item" >
                                <label class="layui-form-label" style="width: 150px">前台预估利润：</label>
                                <div class="layui-input-block">
                                    <input type="radio" name="info[show_future_back]" value="0" {if !$info['id'] || $info['show_future_back']==0}checked{/if} title="隐藏" >
                                    <input type="radio" name="info[show_future_back]" value="1" {if $info['show_future_back']==1}checked{/if} title="显示" >
                                </div>
                                <div class="layui-form-mid layui-word-aux"></div>
                            </div>
                            <div class="layui-form-item" >
                                <label class="layui-form-label" style="width: 150px">业绩未达标：</label>
                                <div class="layui-input-block">
                                    <input type="radio" name="info[circle_add_fail]" value="0" {if !$info['id'] || $info['circle_add_fail']==0}checked{/if} title="不发放" >
                                    <input type="radio" name="info[circle_add_fail]" value="1" {if $info['circle_add_fail']==1}checked{/if} title="按实际增长发放" >
                                </div>
                                <div class="layui-form-mid layui-word-aux"></div>
                            </div>
                        </div>
                        {/if}
                            <div class="layui-form-item">
                                <label class="layui-form-label"></label>
                                <div class="layui-input-inline" style="width:600px;color: #999">
                                    <div>立即返还：</div>
                                    <div style="margin-left: 56px">1、{if getcustom('yx_cashback_sendtype')}付款/{/if}确定收货时立即返回 ；</div>
                                    {if getcustom('yx_cashback_time')}
                                        <div>自 定 义 ：</div>
                                        <div style="margin-left: 56px">1、{if getcustom('yx_cashback_sendtype')}付款/{/if}确认收货后，按天数算出每天应返还的平均数值，若设置小于2天则立即发放全部;{if getcustom('yx_cashback_time_delaysend')}<br>若设置了第几天后开始返现，则会延迟几天才开始返现，0为不延迟（仅支持商城商品延迟天数返现）{/if}</div>
                                        <div style="margin-left: 56px">2、{:t('余额')}和{:t('佣金')}为四舍五入后的保留两位小数平均数值</div>
                                        <div style="margin-left: 56px">3、{:t('积分')}为四舍五入后的整数数值，最小为1，总{:t('积分')}奖励过小会导致发奖完成天数提前许多天;</div>
                                        <div style="margin-left: 56px">4、当返还天数大于等于最后一天时，剩余未还数额将一次性返还，并停止返还</div>
                                    {/if}
                                    {if getcustom('yx_cashback_stage')}
                                        <div>阶梯返还：</div>
                                        <div style="margin-left: 56px">1、{if getcustom('yx_cashback_sendtype')}付款/{/if}确认收货后，按设置的天数范围，给用户返还一定比例的数值</div>
                                        <div style="margin-left: 56px">2、设置时不同阶段相互间天数不要相同</div>
                                        <div style="margin-left: 56px">3、当返还数额大于等于返还比例数额，或返还天数大于等于最后一天时停止返还</div>
                                    {/if}
                                    {if getcustom('yx_cashback_multiply')}
                                    <div>倍增 ：</div>
                                    <div style="margin-left: 56px">1、{if getcustom('yx_cashback_sendtype')}付款/{/if}确认收货后，当前平台业绩作为第一期业绩，返现按订单金额*首期返现比例计算</div>
                                    <div style="margin-left: 56px">2、当平台业绩增长比例满足条件时发放下一期，返现比例也相应增长</div>
                                    <div style="margin-left: 56px">3、一个月内业绩未达到增长比例时月初按实际增长比例返现</div>
                                    <div style="margin-left: 56px">4、总返现金额达到返现比例或返现期数达到总期数时停止返现</div>
                                    <div style="margin-left: 56px">5、业绩仅统计收货完成的订单</div>
                                    {/if}
                                    {if getcustom('yx_cashback_addup_return') && ($auth_data =='all' || in_array('CashbackAddup',$auth_data))}
                                    <div>叠加递减 ：</div>
                                    <div style="margin-left: 56px">1、多个不同的活动可以叠加一起返现，待返金额达到开始返现金额后开始返现，返现超过开始返现金额后停止返现。</div>
                                    <div style="margin-left: 56px">2、返还规则按消费累计金额递减返还。</div>
                                    <div style="margin-left: 56px">3、举例：消费100元，待返金额(100元)=消费金额的100%，每天返还比例5%；</div>
                                    <div style="margin-left: 56px">第一天返待返金额100中的5%就是100*0.05=5，剩余待返金额95元；</div>
                                    <div style="margin-left: 56px">第二天返现95*0.05=4.75，剩余待返金额90.25元；</div>
                                    <div style="margin-left: 56px">然后第二天又消费200元，当前待返金额(100元)=消费金额的50%，剩余待返金额90.25+100=192.25；</div>
                                    <div style="margin-left: 56px">第三天待返金额等于192.25*0.05=9.6125，四舍五入9.61，返现9.61，剩余待返金额182.63；</div>
                                    <div style="margin-left: 56px">有新的消费累加到待返金额内，按这个规则，以此类推。</div>
                                    {/if}
                                </div>
                            </div>
                        {/if}
                        {if getcustom('yx_cashback_yongjin')}
                        <div class="layui-form-item" >
                            <label class="layui-form-label">抵扣佣金提现：</label>
                            <div class="layui-input-inline" style="width:250px">
                                <input type="radio" name="info[cashback_yongjin]" value="0" {if !$info['id'] || $info['cashback_yongjin']==0}checked{/if} title="关闭" />
                                <input type="radio" name="info[cashback_yongjin]" value="1" {if $info['cashback_yongjin']==1}checked{/if} title="开启" />
                            </div>
                            <div class="layui-form-mid layui-word-aux"> 注：开启后在佣金提现时要扣掉已经返现的钱并终止返现</div>
                        </div>
                        {/if}

                        <div class="layui-form-item">
                            <label class="layui-form-label">选择活动商品：</label>
                            <div class="layui-input-inline" style="width:600px">
                                <input type="radio" name="info[fwtype]" value="0" {if $info['fwtype']==0}checked{/if} title="所有商品" lay-filter="fwtype"/>
                                <input type="radio" name="info[fwtype]" value="1" {if $info['fwtype']==1}checked{/if} title="指定类目" lay-filter="fwtype"/>
                                <input type="radio" name="info[fwtype]" value="2" {if $info['fwtype']==2}checked{/if} title="指定商品" lay-filter="fwtype"/>
                                {if getcustom('yx_cashback_collage')}
                                    <input type="radio" name="info[fwtype]" value="3" {if $info['fwtype']==3}checked{/if} title="指定多人拼团" lay-filter="fwtype"/>
                                {/if}
                                {if getcustom('yx_cashback_maidan')}
                                    <input type="radio" name="info[fwtype]" value="4" {if $info['fwtype']==4}checked{/if} title="指定买单" lay-filter="fwtype"/>
                                {/if}
                            </div>
                            <div class="fwtype1" style="clear:both;{if $info['fwtype']!=1}display:none{/if}">
                                <label class="layui-form-label"></label>
                                <div class="layui-input-inline" style="width:auto">
                                    <table id="setcategorydiv"  class="layui-table" style="width:500px">
                                        <thead>
                                        <tr>
                                            <th>分类ID</th>
                                            <th>分类名称</th>
                                            <th>操作</th>
                                        </tr>
                                        </thead>
                                        {if $categorydata}
                                        {foreach $categorydata as $k=>$ff}
                                        <tr class="categorylisttr"><td>{$ff.id}</td><td>{$ff.name}</td><td><button type="button" class="layui-btn layui-btn-sm layui-btn-primary" onclick="delCategory(this,{$ff.id})">删除</button></td></tr>
                                        {/foreach}
                                        {/if}
                                        <tr id="categoryaddtr">
                                            <td colspan="3"><button type="button" class="layui-btn layui-btn-sm layui-btn-primary" onclick="showChooseCategory()">添加</button></td>
                                        </tr>
                                    </table>
                                    <input type="hidden" name="info[categoryids]" value="{$info.categoryids}"/>
                                </div>
                            </div>
                            <script>
                            var chooseCategoryLayer;
                            function showChooseCategory(){
                                chooseCategoryLayer = layer.open({type:2,title:'选择商品分类',content:"{:url('ShopCategory/choosecategory')}",area:['1000px','600px'],shadeClose:true});
                            }
                            function chooseCategory(fid,fname){
                                layer.close(chooseCategoryLayer);
                                var categoryids = [];
                                var isadd = 0;
                                $('.categorylisttr').each(function(){
                                    var thisfid = $(this).find('td:eq(0)').html();
                                    if(thisfid == fid){
                                        isadd = 1
                                        dialog('该分类已添加过了');
                                    }
                                    categoryids.push(thisfid)
                                })
                                if(isadd == 0){
                                    categoryids.push(fid)
                                    $("input[name='info[categoryids]']").val(categoryids.join(','));
                                    $('#categoryaddtr').before('<tr class="categorylisttr"><td>'+fid+'</td><td>'+fname+'</td><td><button type="button" class="layui-btn layui-btn-sm layui-btn-primary" onclick="delCategory(this,'+fid+')">删除</button></td></tr>');
                                }
                                console.log(categoryids)
                            }
                            function delCategory(obj,fid){
                                $(obj).parent().parent().remove();
                                var categoryids = [];
                                $('.categorylisttr').each(function(){
                                    categoryids.push($(this).find('td:eq(0)').html())
                                })
                                $("input[name='info[categoryids]']").val(categoryids.join(','));
                            }
                            </script>
                            <div class="fwtype2" style="clear:both;{if $info['fwtype']!=2}display:none{/if}">
                                <label class="layui-form-label"></label>
                                <div class="layui-input-inline" style="width:auto">
                                    <table id="setproductdiv"  class="layui-table" style="width:700px">
                                        <thead>
                                        <tr>
                                            <th>商品ID</th>
                                            <th>商品名称</th>
                                            <th>操作</th>
                                        </tr>
                                        </thead>
                                        {if $productdata}
                                        {foreach $productdata as $k=>$ff}
                                        <tr class="productlisttr">
                                            <td>{$ff.id}</td>
                                            <td>{$ff.name}</td>
                                            <td><button type="button" class="layui-btn layui-btn-sm layui-btn-primary" onclick="delProduct(this,{$ff.id})">删除</button></td>
                                        </tr>
                                        {/foreach}
                                        {/if}
                                        <tr id="productaddtr">
                                            <td colspan="3"><button type="button" class="layui-btn layui-btn-sm layui-btn-primary" onclick="showChooseProduct()">添加</button></td>
                                        </tr>
                                    </table>
                                    <input type="hidden" name="info[productids]" value="{$info.productids}"/>
                                </div>
                            </div>
                            <script>
                            var cxtype = '{$info.type}';
                            var chooseProductLayer;
                            function showChooseProduct(){
                                var url = "{:url('ShopProduct/chooseproduct')}/showallbusiness/0/hidebid/1";
                                {if getcustom('yx_cashback_yongjin')}
                                url = "{:url('ShopProduct/chooseproduct')}/showallbusiness/true/hidebid/0";
                                {/if}
                                chooseProductLayer = layer.open({type:2,title:'选择商品',content:url,area:['1000px','600px'],shadeClose:true});
                            }
                            function choosepro(res){
                                var product = res.product
                                layer.close(chooseProductLayer);
                                var productids = [];
                                var isadd = 0;
                                $('.productlisttr').each(function(){
                                    var thisfid = $(this).find('td:eq(0)').html();
                                    if(thisfid == product.id){
                                        isadd = 1
                                        dialog('该商品已添加过了');
                                    }
                                    productids.push(thisfid)
                                })
                                if(isadd == 0){
                                    productids.push(product.id)
                                    $("input[name='info[productids]']").val(productids.join(','));
                                    $('#productaddtr').before('<tr class="productlisttr"><td>'+product.id+'</td><td>'+product.name+'</td><td><button type="button" class="layui-btn layui-btn-sm layui-btn-primary" onclick="delProduct(this,'+product.id+')">删除</button></td></tr>');
                                }
                                console.log(productids)
                            }
                            function delProduct(obj,fid){
                                $(obj).parent().parent().remove();
                                var productids = [];
                                $('.productlisttr').each(function(){
                                    productids.push($(this).find('td:eq(0)').html())
                                })
                                $("input[name='info[productids]']").val(productids.join(','));
                            }
                            </script>
                            {if getcustom('yx_cashback_collage')}
                            <div class="fwtype3" style="clear:both;{if $info['fwtype']!=3}display:none{/if}">
                                <div class="layui-form-item">
                                    <label class="layui-form-label"></label>
                                    <div class="layui-input-inline" style="width:auto">
                                        <table id="setproductdiv"  class="layui-table" style="width:700px">
                                            <thead>
                                            <tr>
                                                <th>拼团商品ID</th>
                                                <th>商品名称</th>
                                                <th>操作</th>
                                            </tr>
                                            </thead>
                                            {if $collagedata}
                                            {foreach $collagedata as $k=>$ff}
                                            <tr class="collagelisttr">
                                                <td>{$ff.id}</td>
                                                <td>{$ff.name}</td>
                                                <td><button type="button" class="layui-btn layui-btn-sm layui-btn-primary" onclick="delCollage(this,{$ff.id})">删除</button></td>
                                            </tr>
                                            {/foreach}
                                            {/if}
                                            <tr id="collageaddtr">
                                                <td colspan="3" ><button type="button" class="layui-btn layui-btn-sm layui-btn-primary" onclick="showChooseCollage()">添加</button></td>
                                            </tr>
                                        </table>
                                        <input type="hidden" name="info[collageids]" value="{$info.collageids}"/>
                                    </div>
                                </div>
                            </div>
                            <script>
                            var cxtype = '{$info.type}';
                            var chooseCollageLayer;
                            function showChooseCollage(){
                                chooseCollageLayer = layer.open({type:2,title:'选择商品',content:"{:url('CollageProduct/chooseproduct')}/showtype/all/showallbusiness/true",area:['1000px','600px'],shadeClose:true});
                            }
                            function choosecollage(res){
                                console.log(res)
                                var product = res
                                layer.close(chooseCollageLayer);
                                var collageids = [];
                                var isadd = 0;
                                $('.collagelisttr').each(function(){
                                    var thisfid = $(this).find('td:eq(0)').html();
                                    if(thisfid == product.id){
                                        isadd = 1
                                        dialog('该商品已添加过了');
                                    }
                                    collageids.push(thisfid)
                                })
                                if(isadd == 0){
                                    collageids.push(product.id)
                                    $("input[name='info[collageids]']").val(collageids.join(','));
                                    var html  = '<tr class="collagelisttr"><td>'+product.id+'</td><td>'+product.name+'</td>';
                                    html += '<td><button type="button" class="layui-btn layui-btn-sm layui-btn-primary" onclick="delCollage(this,'+product.id+')">删除</button></td></tr>';
                                    $('#collageaddtr').before(html);
                                }
                                layui.form.render();
                                console.log(collageids)
                            }
                            function delCollage(obj,fid){
                                $(obj).parent().parent().remove();
                                var collageids = [];
                                $('.collagelisttr').each(function(){
                                    collageids.push($(this).find('td:eq(0)').html())
                                })
                                $("input[name='info[collageids]']").val(collageids.join(','));
                            }
                            </script>
                            {/if}
                            {if getcustom('yx_cashback_maidan')}
                            <div class="fwtype4" style="clear:both;{if $info['fwtype']!=4}display:none{/if}">
                                <div class="layui-form-item" >
                                    <label class="layui-form-label">买单参与范围：</label>
                                    <div class="layui-input-inline" style="width:330px">
                                        <input type="radio" name="info[maidan_type]" value="0" {if !$info['id'] || $info['maidan_type']==0}checked{/if} title="全部" />
                                        <input type="radio" name="info[maidan_type]" value="1" {if $info['maidan_type']==1}checked{/if} title="仅平台买单" />
                                        <input type="radio" name="info[maidan_type]" value="2" {if $info['maidan_type']==2}checked{/if} title="仅商户买单" />
                                    </div>
                                </div>
                                <div class="layui-form-item" >
                                    <label class="layui-form-label">买单金额范围：</label>
                                    <div class="layui-input-inline layui-module-itemL">
                                        <div>最低</div>
                                        <input type="text" name="info[maidan_minpaymoney]" class="layui-input" value="{$info.maidan_minpaymoney}">元 ~ 
                                    </div>
                                    <div class="layui-input-inline layui-module-itemL">
                                        <div>最高</div>
                                        <input type="text" name="info[maidan_maxpaymoney]" class="layui-input" value="{$info.maidan_maxpaymoney}">元
                                    </div>
                                    <div class="layui-form-mid layui-word-aux">最高支付金额大于0时起效，否则为无限制</div>
                                </div>
                            </div>
                            {/if}
                        </div>
                        {if getcustom('yx_cashback_collage_moneyreturn')}
                        <div id="moneyreturn" {if !$info['fwtype'] || $info['fwtype']!=3}style="display:none"{/if}>
                            <div class="layui-form-item">
                                <label class="layui-form-label">拼团{:t('余额')}返还：</label>
                                <div class="layui-input-inline" style="width:320px">
                                    <input type="radio" name="info[team_moneyreturn]" value="0" {if $info['id'] && $info['team_moneyreturn']==0}checked{/if} title="关闭" />
                                    <input type="radio" name="info[team_moneyreturn]" value="1" {if !$info['id'] || $info['team_moneyreturn']==1}checked{/if} title="全都返还" />
                                    <input type="radio" name="info[team_moneyreturn]" value="2" {if $info['id'] && $info['team_moneyreturn']==2}checked{/if} title="仅团长返还" />
                                </div>
                                <div class="layui-form-mid layui-word-aux"> 关闭则拼团购买使用{:t('余额')}支付的订单都不返还</div>
                            </div>
                            <div class="layui-form-item" >
                                <label class="layui-form-label">单购{:t('余额')}返还：</label>
                                <div class="layui-input-inline" style="width:320px">
                                    <input type="radio" name="info[alone_moneyreturn]" value="0" {if $info['id'] && $info['alone_moneyreturn']==0}checked{/if} title="关闭" />
                                    <input type="radio" name="info[alone_moneyreturn]" value="1" {if !$info['id'] || $info['alone_moneyreturn']==1}checked{/if} title="开启" />
                                </div>
                                <div class="layui-form-mid layui-word-aux"> 关闭则单独购买使用{:t('余额')}支付的订单不返还</div>
                            </div>
                        </div>
                        {/if}
                        {if getcustom('yx_cashback_time')}
                            {if getcustom('yx_cashback_time_tjspeed')}
                            <div class="layui-form-item" >
                                <label class="layui-form-label">直推上级加速：</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="info[parent_speed]" autocomplete="off" value="{$info.parent_speed}" class="layui-input" id="parent_speed">
                                </div>
                                <div class="layui-form-mid layui-word-aux">% 直推下级购买【购物返现】，按下级商品实际消费额的X%给上级最早的未返现完的购物返现活动加速释放，多出的加速额度给上级累计，下次上级参与新的购物返现活动时进行加速 </div>
                            </div>
                            <div class="layui-form-item" >
                                <label class="layui-form-label">间推上级加速：</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="info[parent2_speed]" autocomplete="off" value="{$info.parent2_speed}" class="layui-input" id="parent2_speed">
                                </div>
                                <div class="layui-form-mid layui-word-aux">%</div>
                            </div>
                            <div class="layui-form-item" >
                                <label class="layui-form-label"></label>
                                <div class="layui-form-mid layui-word-aux">
                                    加速说明：
                                    <br>1、直推、间推上级加速：直推、间推下级购买【购物返现活动】商品且完成时，按下级商品实际消费额的X%(X%：是下级参与购物返现活动设置的直推、间推加速的X%)，<br>给上级最早的、未返现完的购物返现活动进行加速释放
                                    <br>2、多出的加速额度给上级累计，下次上级参与新的购物返现活动时进行加速
                                    <br>3、仅限购物时间选择自定义选项的活动
                                </div>
                            </div>
                            {/if}
                            {if getcustom('yx_cashback_time_teamspeed')}
                            <div id="teamspeedset_div">
                                {php} $teamspeeddata = json_decode($info['teamspeeddata'],true);{/php}
                                {if $teamspeeddata}
                                {foreach $teamspeeddata as $k=>$teamspeed}
                                <div class="layui-form-item">
                                    <label class="layui-form-label">{if $k==0}团队业绩加速：{/if}</label>
                                    <div class="layui-form-mid">达标</div>
                                    <div class="layui-input-inline" style="width:70px"><input type="text" name="money[]" value="{$teamspeed.money}" class="layui-input"></div>
                                    <div class="layui-form-mid">元，加速</div>
                                    <div class="layui-input-inline" style="width:70px"><input type="text" name="speed[]" value="{$teamspeed.speed}" class="layui-input"></div>
                                    <div class="layui-form-mid">%</div>
                                    {if $k==0}
                                    <button type="button" class="layui-btn layui-btn-primary" onclick="adddata()">新增</button>
                                    {else}
                                    <button type="button" class="layui-btn layui-btn-primary" onclick="deldata(this)">删除</button>
                                    {/if}
                                </div>
                                {/foreach}
                                {else}
                                <div class="layui-form-item">
                                    <label class="layui-form-label">团队业绩加速：</label>
                                    <div class="layui-form-mid">达标</div>
                                    <div class="layui-input-inline" style="width:70px"><input type="text" name="money[]" value="" class="layui-input"></div>
                                    <div class="layui-form-mid">元，加速</div>
                                    <div class="layui-input-inline" style="width:70px"><input type="text" name="speed[]" value="" class="layui-input"></div>
                                    <div class="layui-form-mid">%</div>
                                    <button type="button" class="layui-btn layui-btn-primary" onclick="adddata()">新增</button>
                                </div>
                                {/if}
                            </div>
                            <script>
                            function adddata(){
                                var html = '';
                                html+='<div class="layui-form-item">';
                                html+=' <label class="layui-form-label"></label>';
                                html+=' <div class="layui-form-mid">达标</div>';
                                html+=' <div class="layui-input-inline" style="width:70px"><input type="text" name="money[]" value="" class="layui-input"></div>';
                                html+=' <div class="layui-form-mid">元，加速</div>';
                                html+=' <div class="layui-input-inline" style="width:70px"><input type="text" name="speed[]" value="" class="layui-input"></div>';
                                html+=' <div class="layui-form-mid">%</div>';
                                html+=' <button type="button" class="layui-btn layui-btn-primary" onclick="deldata(this)">删除</button>';
                                html+='</div>';
                                $('#teamspeedset_div').append(html);
                            }
                            function deldata(obj){
                                $(obj).parent().remove();
                            }
                            </script>
                            <div class="layui-form-item" >
                                <label class="layui-form-label"></label>
                                <div class="layui-form-mid layui-word-aux">
                                    加速说明：
                                    <br>1、团队业绩加速：若有团队成员完成订单，则统计团队业绩，看是否达标上级正在参与的、购物返现活动的、团队业绩加速标准，达到后上级按达标参数给自己的购物返现活动加速一次
                                    <br>2、多出的加速额度给上级累计，下次上级参与新的购物返现活动时进行加速
                                    <br>3、仅限购物时间选择自定义选项的活动
                                </div>
                            </div>
                            {/if}
                        {/if}

                        <div class="layui-form-item">
                            <label class="layui-form-label">参与条件：</label>
                            <div class="layui-input-inline" style="width:600px">
                                <input type="checkbox" name="info[gettj][]" value="-1" title="所有人" {if in_array('-1',$info['gettj'])}checked{/if}/>
                                <!-- <input type="checkbox" name="info[gettj][]" value="0" title="关注用户" {if in_array('0',$info['gettj'])}checked{/if}/> -->
                                {foreach $memberlevel as $v}
                                <input type="checkbox" name="info[gettj][]" value="{$v.id}" title="{$v.name}" {if in_array($v['id'],$info['gettj'])}checked{/if}/>
                                {/foreach}
                            </div>
                        </div>       
                        {if getcustom('yx_cashback_seckill')}
                        <div class="layui-form-item">
                            <label class="layui-form-label">秒杀参与：</label>
                            <div class="layui-input-inline" style="width:330px">
                                <input type="radio" name="info[seckill_join_status]" value="0" {if !$info['id'] || $info['seckill_join_status']==0}checked{/if} title="关闭" />
                                <input type="radio" name="info[seckill_join_status]" value="1" {if $info['seckill_join_status']==1}checked{/if} title="开启" />
                            </div>
                            <div class="layui-form-mid layui-word-aux">参与秒杀活动，开启后，秒杀商品中可控制是否参与</div>
                        </div>
                        {/if}
                        <div class="layui-form-item">
                            <label class="layui-form-label">开始时间：</label>
                            <div class="layui-input-inline">
                                <input type="text" name="info[starttime]" autocomplete="off" value="{$info.starttime}" lay-verify="required" lay-verType="tips" class="layui-input" id="starttime">
                            </div>
                            <div class="layui-form-mid layui-word-aux">活动开始时间</div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">结束时间：</label>
                            <div class="layui-input-inline">
                                <input type="text" name="info[endtime]" autocomplete="off" value="{$info.endtime}" lay-verify="required" lay-verType="tips" class="layui-input" id="endtime">
                            </div>
                            <div class="layui-form-mid layui-word-aux">活动结束时间</div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">序号：</label>
                            <div class="layui-input-inline">
                                <input type="text" name="info[sort]" value="{$info.sort}" class="layui-input">
                            </div>
                            <div class="layui-form-mid layui-word-aux">用于排序,越大越靠前</div>
                        </div>
                        <div class="layui-form-item">
							<label class="layui-form-label"></label>
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit lay-filter="formsubmit">提 交</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
    </div>
  </div>
    {include file="public/js"/}
    <script>
    layui.form.on('radio(group_status)',function(data){
        if(data.value == 1){
            $('.group_status1').show();
        }else{
            $('.group_status1').hide();
        }
    })
    layui.form.on('radio(fwtype)',function(data){
        if(data.value==1){
            $('.fwtype1').show();
            $('.fwtype2').hide();
            $('.fwtype3').hide();
            $('.fwtype4').hide();
            $('#moneyreturn').hide();

        }else if(data.value==2){
            $('.fwtype1').hide();
            $('.fwtype2').show();
            $('.fwtype3').hide();
            $('.fwtype4').hide();
        }else if(data.value==3){
            $('.fwtype1').hide();
            $('.fwtype2').hide();
            $('.fwtype3').show();
            $('.fwtype4').hide();
            $('#moneyreturn').show();
        }else if(data.value==4){
            $('.fwtype1').hide();
            $('.fwtype2').hide();
            $('.fwtype3').hide();
            $('.fwtype4').show();
            $('#moneyreturn').show();
        }else{
            $('.fwtype1').hide();
            $('.fwtype2').hide();
            $('.fwtype3').hide();
            $('.fwtype4').hide();
            $('#moneyreturn').hide();
        }
    })
    {if getcustom('yx_cashback_time') || getcustom('yx_cashback_multiply')}
    layui.form.on('radio(return_type)',function(data){
        if(data.value==1){
            $('.return_type1').show();
            $('.return_type2').hide();
            $('.return_type3').hide();
            $('#delaysend_day').show();
            $('#return_day').show();
            $('#jiange_day').show();
        }else if(data.value==2){
            $('.return_type1').hide();
            $('.return_type2').show();
            $('#delaysend_day').hide();
            $('#return_day').hide();
            $('#jiange_day').hide();
        }else if(data.value==3){
            $('.return_type1').hide();
            $('.return_type2').hide();
            $('.return_type3').show();
            $('#delaysend_day').hide();
            $('#return_day').hide();
            $('#jiange_day').hide();
        }else{
            $('.return_type1').hide();
            $('.return_type2').hide();
            $('.return_type3').hide();
            $('#delaysend_day').hide();
            $('#return_day').show();
            $('#jiange_day').show();
        }
    })
    {/if}
    layui.laydate.render({
        elem: '#starttime'
        ,type: 'datetime'
        ,range: false,
        trigger: 'click'
    });
    layui.laydate.render({
        elem: '#endtime'
        ,type: 'datetime'
        ,range: false,
        trigger: 'click'
    });

    layui.form.on('submit(formsubmit)', function(obj){
        console.log(obj)
        var field = obj.field
        var index = layer.load();
        $.post("{:url('save')}",field,function(data){
            layer.close(index);
            dialog(data.msg,data.status);
            if(data.status == 1){
                setTimeout(function(){
                    parent.layer.closeAll();
                    parent.tableIns.reload()
                },1000)
            }
        })
    })
  </script>
    {include file="public/copyright"/}
</body>
</html>